from flask import Flask
from flask_restful import Api
from flask_cors import CORS
import config
from api.login import logapi
from db import db


def create_app(config_name):
    app = Flask(__name__)
    CORS(app, supports_credentials=True)
    app.config.from_object(config.env[config_name])
    db.init_app(app)
    # 返回数据中response为中文
    app.config['JSON_AS_ASCII'] = False
    logapi.init_app(app)
    return app
